﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace CapaPresentacion.Converters
{
    [ValueConversion(typeof(bool?), typeof(bool))]
    internal class NullableBooleanToBooleanConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Boolean? booleanValue = value as Boolean?;

            return booleanValue.HasValue ? booleanValue.Value : false;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return new Boolean?((Boolean)value);
        }
    }
}
